package cate.common.table.activity.exorcism.sheet;


import cate.common.table.ESheet;
import cate.common.table.activity.exorcism.row.ExorcismRandomRwdRow;
import cate.common.util.random.RWList;
import easy.java.dev.note.NoteClass;

import java.util.HashMap;
import java.util.Map;

@NoteClass("驱魔之夜-随机奖励")
public class ExorcismRandomRwdSheet extends ESheet<ExorcismRandomRwdRow> {

    @Override
    public String getSheetName() {
        return "随机奖励";
    }

    private Map<Integer, RWList<ExorcismRandomRwdRow>> groupMap;

    @Override
    protected void onLoaded() {
        groupMap = new HashMap<>();
        for (ExorcismRandomRwdRow row : this.getList()) {
            RWList<ExorcismRandomRwdRow> rwList = groupMap.get(row.group);
            if (rwList == null) {
                rwList = new RWList<>();
                groupMap.put(row.group, rwList);
            }
            rwList.add(row);
        }
        groupMap.values().forEach(RWList::setup);
    }

    public ExorcismRandomRwdRow random(int group) {
        RWList<ExorcismRandomRwdRow> rwList = groupMap.get(group);
        if (rwList == null) {
            return null;
        }
        return rwList.get();
    }

}
